home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office german / PROPLUS.WW / PROPLSWW.CAB / AUTHOR2XML.XSL < prev    next >
Extensible Markup Language  |  2006-07-09  |  4KB  |  116 lines

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:b="http://schemas.openxmlformats.org/officeDocument/2006/bibliography">
  3.     <xsl:output method="xml" encoding="us-ascii"/>
  4.     <xsl:template match="Field">
  5.         <xsl:variable name="Authors"><xsl:value-of select="."/></xsl:variable>
  6.  
  7.         <b:NameList>
  8.             <xsl:call-template name="ParseNames">
  9.                 <xsl:with-param name="Source" select="$Authors"/>
  10.             </xsl:call-template>
  11.         </b:NameList>
  12.     </xsl:template>
  13.  
  14.     <xsl:template name="ParseNames">
  15.         <xsl:param name="Source"/>
  16.  
  17.         <xsl:variable name="OneName">
  18.             <xsl:value-of select="normalize-space(substring-before($Source, ';'))"/>
  19.         </xsl:variable>
  20.         <xsl:variable name="RestName">
  21.             <xsl:value-of select="normalize-space(substring-after($Source, ';'))"/>
  22.         </xsl:variable>
  23.  
  24.         <xsl:call-template name="ParseName">
  25.             <xsl:with-param name="Source" select="normalize-space($OneName)"/>
  26.         </xsl:call-template>
  27.  
  28.         <xsl:if test="string-length($RestName) > 0">
  29.             <xsl:call-template name="ParseNames">
  30.                 <xsl:with-param name="Source" select="normalize-space($RestName)"/>
  31.             </xsl:call-template>
  32.         </xsl:if>
  33.     </xsl:template>
  34.  
  35.     <xsl:template name="LastOf">
  36.         <xsl:param name="Source"/>
  37.         <xsl:choose>
  38.             <xsl:when test="contains($Source, ' ')">
  39.                 <xsl:call-template name="LastOf">
  40.                     <xsl:with-param name="Source" select="substring-after($Source, ' ')"/>
  41.                 </xsl:call-template>
  42.             </xsl:when>
  43.             <xsl:otherwise>
  44.                 <xsl:value-of select="$Source"/>
  45.             </xsl:otherwise>
  46.         </xsl:choose>
  47.     </xsl:template>
  48.  
  49.  
  50.     <xsl:template name="ParseName">
  51.         <xsl:param name="Source"/>
  52.  
  53.             <xsl:variable name="Last">
  54.                 <xsl:choose>
  55.                     <xsl:when test="contains($Source, ',')">
  56.                         <xsl:value-of select="normalize-space(substring-before($Source, ','))"/>
  57.                     </xsl:when>
  58.                     <xsl:when test="contains($Source, ' ') and string-length(normalize-space(substring-after($Source, ' '))) > 0">
  59.                         <xsl:call-template name="LastOf">
  60.                             <xsl:with-param name="Source" select="$Source"/>
  61.                         </xsl:call-template>
  62.                     </xsl:when>
  63.                     <xsl:otherwise>
  64.                         <xsl:value-of select="normalize-space($Source)"/>
  65.                     </xsl:otherwise>
  66.                 </xsl:choose>
  67.             </xsl:variable>
  68.             
  69.             <xsl:variable name="FirstMiddle">
  70.                 <xsl:choose>
  71.                     <xsl:when test="contains($Source, ',') and string-length(normalize-space(substring-after($Source, ','))) > 0">
  72.                         <xsl:value-of select="normalize-space(substring-after($Source, ','))"/>
  73.                     </xsl:when>
  74.                     <xsl:when test="contains($Source, ' ') and string-length(normalize-space(substring-before($Source, ' '))) > 0">
  75.                         <xsl:value-of select="normalize-space(substring($Source, 1, string-length($Source) - string-length($Last) - 1))"/>
  76.                     </xsl:when>
  77.                 </xsl:choose>
  78.             </xsl:variable>
  79.             
  80.             <xsl:variable name="First">
  81.                 <xsl:choose>
  82.                     <xsl:when test="contains($FirstMiddle, ' ')">
  83.                         <xsl:value-of select="normalize-space(substring-before($FirstMiddle, ' '))"/>
  84.                     </xsl:when>
  85.                     <xsl:otherwise>
  86.                         <xsl:value-of select="$FirstMiddle"/>
  87.                     </xsl:otherwise>
  88.                 </xsl:choose>
  89.             </xsl:variable>
  90.             
  91.             <xsl:variable name="Middle">
  92.                 <xsl:choose>
  93.                     <xsl:when test="contains($FirstMiddle, ' ')">
  94.                         <xsl:value-of select="normalize-space(substring-after($FirstMiddle, ' '))"/>
  95.                     </xsl:when>
  96.                 </xsl:choose>
  97.             </xsl:variable>
  98.  
  99.         <xsl:if test="string-length($Last) > 0">
  100.             <b:Person>
  101.                 <b:Last><xsl:value-of select="$Last"/></b:Last>
  102.                 <b:First><xsl:value-of select="$First"/></b:First>
  103.                 <b:Middle><xsl:value-of select="$Middle"/></b:Middle>
  104.             </b:Person>
  105.         </xsl:if>
  106.         <xsl:if test="string-length($Last) = 0 and (string-length($First) > 0 or string-length($Middle) > 0 )">
  107.             <b:Person>
  108.                 <b:Last></b:Last>
  109.                 <b:First><xsl:value-of select="$First"/></b:First>
  110.                 <b:Middle><xsl:value-of select="$Middle"/></b:Middle>
  111.             </b:Person>
  112.         </xsl:if>
  113.     </xsl:template>
  114. </xsl:stylesheet>
  115.  
  116.